<template>
  <div>
    <Header :point="point" @setPoint="setPoint" @searchUpdata="searchUpdata"></Header>
    <Login v-if="point" @setPoint="setPoint"></Login>
    <Detailed :datas="datas"></Detailed>
    <router-view></router-view>
  </div>
</template>
  
  <script>
import Header from "./components/Header.vue";
import Login from "./components/Login";
import axios from "axios";
import router from "./router";
import VueCookies from "vue-cookies";
import Detailed from './components/Detailed.vue';

export default {
  name: "App",
  router:router,
  components: {
    Header,
    Login,
    Detailed,
  },
  created() {
    // 钩子函数，插件完调用函数
    this.getDatas();
  },
  methods: {
    setPoint: function () {
      this.point = !this.point;
    },
    searchUpdata:function(data){
      // header组件进行搜索时，详细页面datas数据更新
      this.datas = data
    },
    getDatas: function () {
      // 获取数据
      axios({
        method: "POST",
        url: "http://localhost:8081/lo/intercept/goods/getgoodsasid",
        params: {
          uid: VueCookies.get("uid"),
          ucookie: VueCookies.get("ucookie"),
          gid: VueCookies.get("gid"),
        },
        headers: {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded",
          },
        },
      }).then(
        (response) => {
          // console.log(response.data);
          this.datas = response.data
          console.log(this.id);
        },
        (error) => {
          alert("请求失败,请检查服务器是否开启！");
        }
      );
    },
    
  },
  data() {
    return {
      point: 0, // 初始化登录注册界面
      datas: {
        gid: "",
        gname: "",
        price: "",
        date: "",
        detailed: "",
        gtype: "",
        url:'logo.png'
      },
      // id: window.document.location.href.split("?")[1].split("=")[1],
    };
  },
};
</script>
  
  <style scoped>

</style>
  